package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.Data;
import com.service.LiuYan;

/**
 * Servlet implementation class LiuYanServlet
 */
@WebServlet("/LiuYanServlet")
public class LiuYanServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LiuYanServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//设置传值的格式，确保中文正常存入数据库 
		request.setCharacterEncoding("utf-8");
		//getParameter("");取得是表单元素的name的值
		String name=request.getParameter("name");
		String tel=request.getParameter("tel");
		String email=request.getParameter("email");
		String content=request.getParameter("content");
		String yanzhengma=request.getParameter("yanzhengma");
		
		Data aa=new Data();
		LiuYan ly=new LiuYan();
		ly.setUserName(name);
		ly.setTel(tel);
		ly.setEmail(email);
		ly.setContent(content);
		
		if(aa.dataInsert(ly)>0){
			System.out.println("ok");
		}
		else{
			System.out.println("no");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
